package com.ruoyi.system.service.congyuhui.impl;

import java.util.List;

import com.ruoyi.system.domain.chongyuhui.TbSwipperEntity;
import com.ruoyi.system.mapper.chongyuhui.TbSwipperMapper;
import com.ruoyi.system.service.congyuhui.TbSwipperService;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.apache.ibatis.session.SqlSessionFactory;

/**
 * (TbSwipper)表服务实现类
 *
 * @author makejava
 * @since 2024-05-27 22:58:52
 */
@Service
public class TbSwipperServiceImpl implements TbSwipperService {

    @Autowired
    private TbSwipperMapper tbSwipperMapper;

    @Resource
    private SqlSessionFactory sqlSessionFactory;

    /**
     * 新增
     */
    @Override
    public void insert(TbSwipperEntity tbSwipperEntity) {
        tbSwipperMapper .insert(tbSwipperEntity);
    }

    /**
     * 批量新增
     */
    @Override
    public void batchInsert(List<TbSwipperEntity> tbSwipperEntities) {
        SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH,false);
        TbSwipperMapper mapper = sqlSession.getMapper(TbSwipperMapper .class);
        tbSwipperEntities .stream().forEach(tbSwipperEntity -> mapper.insert(tbSwipperEntity));
        sqlSession.commit();
        sqlSession.clearCache();
    }


    /**
     * 刪除
     */
    @Override
    public void delete(TbSwipperEntity tbSwipperEntity) {
        tbSwipperMapper .delete(tbSwipperEntity);
    }

    /**
     * 批量刪除
     */
    @Override
    public void batchDelete(List<TbSwipperEntity> tbSwipperEntities) {
        tbSwipperMapper .batchDelete(tbSwipperEntities);
    }

    /**
     * 编辑
     */
    @Override
    public void update(TbSwipperEntity tbSwipperEntity) {
        tbSwipperMapper .update(tbSwipperEntity);
    }

    /**
     * 批量编辑
     */
    @Override
    public void batchUpdate(List<TbSwipperEntity> tbSwipperEntities) {
        tbSwipperMapper .batchUpdate(tbSwipperEntities);
    }


    /**
     * 查询
     */
    @Override
    public List<TbSwipperEntity> query(TbSwipperEntity tbSwipperEntity) {
        return tbSwipperMapper .select(tbSwipperEntity);
    }


}

